<?php

ob_start('ob_gzhandler');

header('Content-type: text/css; charset: UTF-8');
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);

$baseUrl = preg_replace('/\/assets\/styles\/css.php.*/', '', ((array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);

if (isset($_GET['include'])){
  $includes = explode(',', $_GET['include']);
  foreach($includes as $include){
    $contents = file_get_contents(dirname(__FILE__) . "/$include.css");
    $contents = preg_replace('/%images%/', $baseUrl . '/assets/images', $contents);
    echo $contents;
  }
}

ob_end_flush();
?>